package com.dsh.admin.action;

import java.util.Date;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dsh.admin.entity.ShopUser;
import com.dsh.admin.manager.ShopUserMng;

@Controller
@RequestMapping("/shopUser")
public class ShopUserAct {
	@RequestMapping("/edit.do")
	public String editShopUser(HttpServletRequest request,HttpServletResponse response,Model model){
		HttpSession session = request.getSession();
		ShopUser user = (ShopUser)session.getAttribute("user");
		if(user!=null){
			user = shopUserMng.findById(user.getId());
		}
		model.addAttribute("bean", user);
		return "bms/admin/shopuser/edit";
	}
	
	
	@RequestMapping("/update.do")
	@ResponseBody
	public String updateShopUser(HttpServletRequest request,HttpServletResponse response,Model model,ShopUser bean){
		try {
			Date date = new Date();
			bean.setUpdate_date(date);
			bean = shopUserMng.update(bean);
		} catch (Exception e) {
			e.printStackTrace();
			return "2";
		}
		return "1";
	}
	
	
	@Resource(name="shopUserMngImpl")
	private ShopUserMng shopUserMng;//管理员信息
	
}
